package gui;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class StartScreen extends JFrame {

	private JPanel centerPane;
	private JPanel produttorePane;
	private JPanel consumatorePane;

	public StartScreen() {
		super("Produttore-Consumatore");
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLayout(new BorderLayout());
		// setIconImage(Toolkit.getDefaultToolkit().getImage("img/SuperMario.png"));
		initCenterPanel();
		this.setExtendedState(MAXIMIZED_BOTH);
		setLocationByPlatform(true);
		setResizable(false);
		pack();
		setVisible(true);
	}

	private void initCenterPanel() {
		// I pannelli devono disegnarsi in base al model
		centerPane = new JPanel(new GridBagLayout());

		produttorePane = new PCPanel(PCPanel.PRODUTTORE);
		consumatorePane = new PCPanel(PCPanel.CONSUMATORE);

		centerPane.add(produttorePane, new GridBagConstraints(0, 0, 1, 1, 1.0,
				1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
				new Insets(10, 10, 5, 2), 0, 0));
		centerPane.add(consumatorePane, new GridBagConstraints(1, 0, 1, 1, 1.0,
				1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
				new Insets(10, 10, 5, 2), 0, 0));

		StartScreen.this.add(centerPane, BorderLayout.CENTER);

	}

	public JPanel getCenterPane() {
		return centerPane;
	}

	public static void main(String[] args) {
		new StartScreen();
	}
}
